<template>
    <div style="margin-top: 60px;margin-left:40px;border: 0px solid red;" >
        <el-form style="margin-left: -40px" label-width="100px" class="demo-ruleForm">
        </el-form>

       <el-table
                :data="tableData"
                border
                stripe
                style="width: 100%;position: relative;top:-30px">
                  <el-table-column
                    fixed
                    prop="cpId"
                    label="ID"
                    width="40">
              </el-table-column>
                <el-table-column
                    fixed
                    prop="name"
                    label="公司名称"
                    width="150">
              </el-table-column>
            <el-table-column
                    fixed
                    prop="num"
                    label="规模(人数)"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="area"
                    label="地址"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="estTime"
                    label="创建时间"
                    width="100">
            </el-table-column>
             <el-table-column
                    prop="industryType"
                    label="公司类型"
                    width="110">
            </el-table-column>
            <el-table-column
                    prop="regMoney"
                    label="注册资金"
                    width="100" >
            </el-table-column>
              <el-table-column
                    prop="license"
                    label="是否上市"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="regName"
                    label="CEO"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="brief"
                    label="简介"
                    width="100">
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                            size="mini"
                            @click="edit(scope.row)">编辑</el-button>
                    <el-button
                            size="mini"
                            type="danger"
                            @click="del(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>

</template>

<script>
    export default {
        data() {
            return {
                tableData:null,
            }
        },
        methods:{
            
            /* 修改功能 */
            edit(row){
              
                this.$router.push('/updateCompany?id='+row.cpId)
            },
            /* 删除功能 */
            del(row) {
                const _this = this
                this.$confirm('确认删除【'+row.name+'】吗？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.delete('http://localhost:8182/company/deleteById/'+row.cpId).then(function (resp) {
                        if(resp.data.code==0){
                            _this.$alert('【'+row.name+'】已删除', '', {
                                confirmButtonText: '确定',
                                callback: action => {
                                    location.reload()
                                }
                            });
                        }
                    });
                });
            }
        },
        created() {
        const _this = this
        let companyuser = JSON.parse(window.localStorage.getItem('companyuser'))
        this.companyuser = companyuser
       console.log(_this.companyuser.cuid)
            axios.get('http://localhost:8182/company/list/' +'/'+_this.companyuser.cuid).then(function (resp) {
              /* console.log(resp.data)  */
                _this.tableData = resp.data.data
              /*  console.log(resp.data) */
            })
        }
        
    }
</script>